import 'package:json_annotation/json_annotation.dart';

part 'get_consultation_res.g.dart';

@JsonSerializable(fieldRename: FieldRename.none)
class GetConsultationRes {
  final int? code;
  final Data? data;
  final String? msg;

  const GetConsultationRes({
    this.code,
    this.data,
    this.msg,
  });

  factory GetConsultationRes.fromJson(Map<String, dynamic> json) =>
      _$GetConsultationResFromJson(json);

  Map<String, dynamic> toJson() => _$GetConsultationResToJson(this);

  GetConsultationRes copyWith({
    int? code,
    Data? data,
    String? msg,
  }) {
    return GetConsultationRes(
      code: code ?? this.code,
      data: data ?? this.data,
      msg: msg ?? this.msg,
    );
  }
}

@JsonSerializable(fieldRename: FieldRename.none)
class Data {
  final List<ConsultationModel>? list;
  final int? total;

  const Data({
    this.list,
    this.total,
  });

  factory Data.fromJson(Map<String, dynamic> json) =>
      _$DataFromJson(json);

  Map<String, dynamic> toJson() => _$DataToJson(this);

  Data copyWith({
    List<ConsultationModel>? list,
    int? total,
  }) {
    return Data(
      list: list ?? this.list,
      total: total ?? this.total,
    );
  }
}

@JsonSerializable(fieldRename: FieldRename.none)
class ConsultationModel {
  final int? id;
  final int? pid;
  final int? did;
  final bool? status;
  final int? rating;
  final int? createTime;
  final String? didName;
  final String? didAvatar;
  final String? pidName;
  final String? pidAvatar;
  final String? latestMessageContent;
  final int? latestMessageSenderId;
  final int? latestMessageType;
  final int? latestMessageTime;

  const ConsultationModel({
    this.id,
    this.pid,
    this.did,
    this.status,
    this.rating,
    this.createTime,
    this.didName,
    this.didAvatar,
    this.pidName,
    this.pidAvatar,
    this.latestMessageContent,
    this.latestMessageSenderId,
    this.latestMessageType,
    this.latestMessageTime,
  });

  factory ConsultationModel.fromJson(Map<String, dynamic> json) =>
      _$ConsultationModelFromJson(json);

  Map<String, dynamic> toJson() => _$ConsultationModelToJson(this);

  ConsultationModel copyWith({
    int? id,
    int? pid,
    int? did,
    bool? status,
    int? rating,
    int? createTime,
    String? didName,
    String? didAvatar,
    String? pidName,
    String? pidAvatar,
    String? latestMessageContent,
    int? latestMessageSenderId,
    int? latestMessageType,
    int? latestMessageTime,
  }) {
    return ConsultationModel(
      id: id ?? this.id,
      pid: pid ?? this.pid,
      did: did ?? this.did,
      status: status ?? this.status,
      rating: rating ?? this.rating,
      createTime: createTime ?? this.createTime,
      didName: didName ?? this.didName,
      didAvatar: didAvatar ?? this.didAvatar,
      pidName: pidName ?? this.pidName,
      pidAvatar: pidAvatar ?? this.pidAvatar,
      latestMessageContent: latestMessageContent ?? this.latestMessageContent,
      latestMessageSenderId: latestMessageSenderId ?? this.latestMessageSenderId,
      latestMessageType: latestMessageType ?? this.latestMessageType,
      latestMessageTime: latestMessageTime ?? this.latestMessageTime,
    );
  }
}
